package cn.jinjimi.app.main.widget.CommonRV;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

/**
 * Created by lforxeverc on 2017/3/15.
 */
public abstract class BaseHolder<D extends IViewData> extends RecyclerView.ViewHolder {
    final Context mContext;
    final int viewType;

    public BaseHolder(View v, Context context, int type) {
        super(v);
        this.mContext = context;
        this.viewType = type;
        initView();
    }

    public static View createView(Context ctx, int layoutId) {
        return LayoutInflater.from(ctx).inflate(layoutId, null);
    }

    public static View createView(Context ctx, int layoutId, ViewGroup vg) {
        return LayoutInflater.from(ctx).inflate(layoutId, vg);
    }

    public int getViewType() {
        return viewType;
    }

    protected abstract void initView();

    public abstract void setViews(int position, D data, IActionListener mListener);

    public View getItemView() {
        return itemView;
    }

    public Context getContext() {
        return mContext;
    }

    public void updateOnView() {
    }
}